import { RouteRecordRaw } from 'vue-router';
import { Layout } from '@/router/constant';
import { WindowsOutlined } from '@vicons/antd';
import { renderIcon } from '@/utils/index';

/**
 * @param name 路由名称, 必须设置,且不能重名
 * @param meta 路由元信息（路由附带扩展信息）
 * @param redirect 重定向地址, 访问这个路由时,自定进行重定向
 * @param meta.disabled 禁用整个菜单
 * @param meta.title 菜单名称
 * @param meta.icon 菜单图标
 * @param meta.keepAlive 缓存该路由
 * @param meta.sort 排序越小越排前
 *
 * */
const routes: Array<RouteRecordRaw> = [
  {
    path: '/plugins',
    name: 'plugins',
    redirect: '/plugins/dataSource',
    component: Layout,
    meta: {
      title: '在线开发',
      icon: renderIcon(WindowsOutlined),
      sort: 6,
      permissions: ['plugins_dataSource'],
    },
    children: [
      {
        path: 'dataSource',
        name: 'plugins_dataSource',
        meta: {
          title: '数据源管理',
          permissions: ['plugins_dataSource'],
        },
        component: () => import('@/views/plugins/dataSource/dataSourceConf.vue'),
      },
      {
        path: 'template',
        name: 'template',
        meta: {
          title: '模板管理',
          permissions: ['plugins_template'],
        },
        component: () => import('@/views/plugins/codeTemplate/templateList.vue'),
      },
      {
        path: 'model',
        name: 'model_design',
        meta: {
          title: '模型设计',
          permissions: ['model_design'],
        },
        component: () => import('@/views/plugins/modelDesign/modelDesign.vue'),
      },
      {
        path: 'formDesign',
        name: 'formDesign',
        meta: {
          title: '表单设计',
          permissions: ['plugins_formDesign'],
        },
        component: () => import('@/views/formDesign/formDesign.vue'),
      },
      {
        path: 'projectCode',
        name: 'projectCode',
        meta: {
          title: '项目模板',
          permissions: ['plugins_projectCode'],
        },
        component: () => import('@/views/plugins/projectCode/projectCode.vue'),
      },
    ],
  },
];

export default routes;
